package com.framework.seedkit.ui;

import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
import android.widget.TextView;

import com.framework.seedkit.R;
import com.framework.seedkit.base.BaseActivity;

import butterknife.BindView;

/**
 * Created by ekimatsu on 16/12/12.
 */

public class SwipeRefreshLayoutAct extends BaseActivity{
    @BindView(R.id.swipe_container)
    SwipeRefreshLayout swipe_container;
    @BindView(R.id.swipe_txt)
    TextView swipe_txt;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.act_swiperefresh_layout;
    }

    @Override
    public void initView() {
        swipe_container.setColorSchemeColors(R.color.red_color, R.color.swiperefresh_color2, R.color.swiperefresh_color3, R.color.swiperefresh_color2);
        swipe_container.setSize(SwipeRefreshLayout.DEFAULT);
        swipe_container.setProgressViewEndTarget(true, 100);
        swipe_container.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                swipe_txt.setText(R.string.swipe_to_refresh);

                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        swipe_txt.setText(R.string.swipe_complete_refresh);
                        swipe_container.setRefreshing(false);
                    }
                }, 3000);
            }
        });
    }

    @Override
    public void initData() {
        super.initData();
    }
}
